# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: teacher_interface.py
Author: kij
Create Date: 2021/2/22
-------------------------------------------------
"""
from modle.modles import Teacher
from interface import common_interface


# 管理自己的课程
def all_lesson_interface(teacher_name):
	teacher = Teacher.get_data(teacher_name)
	all_lesson = teacher.lessons
	if all_lesson:
		return True, all_lesson
	else:
		return False, '你还没有选择课程'


# 拿到学校
def get_my_school(teacher_name):
	teacher = Teacher.get_data(teacher_name)
	school_list = common_interface.get_all_school(teacher.admin_name)
	if school_list:
		return True, school_list
	else:
		return False, '你家机构没有学校呢'


# 选择班级
def add_lesson_interface(teacher_name, lesson_name):
	teacher = Teacher.get_data(teacher_name)

	lesson = teacher.lessons
	if lesson_name in lesson:
		return False, '已经选择了该课程'
	teacher.add_lesson(lesson_name)
	return True, '%s课程添加成功' % lesson_name


# 查看班级学员列表
def student_list_interface(teacher_name, lesson_name):
	teacher = Teacher.get_data(teacher_name)
	student_list = teacher.get_student(lesson_name)
	if student_list:
		return True, student_list
	else:
		return False, '课程下没有学生'


# 修改所管理的学员的成绩
def change_student_num_interface(teacher_name, lesson_name, student_name, num):
	teacher = Teacher.get_data(teacher_name)
	teacher.change_score(student_name, lesson_name, num)
	return True, "修改成功"
